<?php

$conexion = oci_connect("roger","roger","localhost/xe","AL32UTF8");

	$consulta="SELECT * FROM usuario";
	$resultado=oci_parse($conexion,$consulta);
	oci_execute($resultado);

$no_elements=10;
$page2=1;


     if(isset($_GET['page'])){
	$page=$_GET['page'];
        }
        else{
               $page=1;
               

                  }

if($page<=$page2){
      $page2=1;
      $no_elements2=10;
      $b=10;
}

else{
     $page2= ((($page-1)*10)+1) ;
     $no_elements2= ($page * 10);
}


         $con1= ("select * from (select t.*, row_number() over (order by matricula asc) r from usuario t) where r between ".$page2." and ".$no_elements2);




         
         

	$resul= oci_parse($conexion,$con1);
	oci_execute($resul);

	
	$sql = ("SELECT COUNT(*) AS total FROM usuario");
    	$result = oci_parse($conexion,$sql);
	oci_execute($result);
	$total=oci_fetch_array($result);
      

?>

<!doctype html>
<html lang="en">
	<head>
		<title>Lista de Usuarios</title>
<script type="text/javascript" src="ajax.js"></script>

	<meta charset="utf-8" />
	<title>Administracion de ususarios</title>
	<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
	<link rel="stylesheet" type="text/css" href="print.css" media="print" />

			<style type="text/css" media="screen">
		h1.fontface {font: 32px/38px 'MichromaRegular', Arial, sans-serif;letter-spacing: 0;}

		p.style1 {font: 18px/27px 'MichromaRegular', Arial, sans-serif;}
		
		
		@font-face {
    font-family: 'MichromaRegular';
    src: url('Michroma-webfont.eot');
    src: url('Michroma-webfont.eot?#iefix') format('embedded-opentype'),
         url('Michroma-webfont.woff') format('woff'),
         url('Michroma-webfont.ttf') format('truetype'),
         url('Michroma-webfont.svg#MichromaRegular') format('svg');
    font-weight: normal;
    font-style: normal;

}
	</style>


	
	
</head>
<!-- aqui termina el diseño-->
	<body>
       
<header>
 <div class="container1">
    <!--start title-->
    <h1 class="fontface" id="title">Administrador</h1>
	<!--end title-->

  </div>
    
	</header>
	<!--end header-->
 
<nav>
<div class="menu">
    <ul>
    
    <li><a href="http://localhost/sesiones/nuevo.php">Agragar Ususario</a></li>
    <li><a href="http://localhost/sesiones/busqueda.html">Buscar Usuario</a></li>
    <li><a href="http://localhost/sesiones/desconectar_usuario.php">Cerrar Sesion</a></li>
    </ul>
	</div>
    </nav>
	<div id="wrapper"><!-- #wrapper -->
	<section id="main"><!-- #main content and sidebar area -->

<!-- aqui empieza el diseño-->

		
		<p></p>
		
		<table align="center" border=8 width="80%">
			<thead>

				<tr>
                                        <td><b>Matricula</b></td>
					<td><b>Usuario</b></td>
					<td><b>Paterno</b></td>
					<td><b>Materno</b></td>
					<td><b>Correo</b></td>
					<td></td>
					<td></td>
				</tr>
 
  <tr>
				<tbody>
					<?php while($fila=oci_fetch_array($resul)){ ?>
						<tr>
							<td><?php echo $fila[MATRICULA];?></td>
                                                        <td><?php echo $fila[NOMBRE];?></td>
							<td><?php echo $fila[APELLIDO_PAT];?></td>
							<td><?php echo $fila[APELLIDO_MAT];?></td>
							<td><?php echo $fila[CORREO];?></td>
							<td>
								<a href="modificar.php?id=<?php echo $fila['MATRICULA'];?>">Modificar</a>
							</td>
							<td>
								<a href="eliminar.php?id=<?php echo $fila['MATRICULA'];?>">Eliminar</a>
							</td>
						</tr>

					<?php } ?>
				</tbody>
			</table>
<div align="center" class="gigantic pagination">
<a href="index.php?page=<?php echo ($page-1)==0?$page:$page-1; ?>" class="previous" data-action="previous">&lsaquo;</a>
<?php echo $page;?> 

<a href="index.php?page=<?php echo ($page+1)>(($total[0]/ $no_elements)+1) ?$page:$page+1;?>" class="next" data-action="next">&rsaquo;</a>
</div>

		</body>
	</html>	
	
